export const NowTime = () => {
  var time = new Date();
  var year = time.getFullYear(); //获取年
  var month = time.getMonth() + 1; //或者月
  var date = time.getDate(); //或者天
  var hour = time.getHours(); //获取小时
  var minu = time.getMinutes(); //获取分钟
  var second = time.getSeconds(); //或者秒
  if (month < 10) {
    month = '0' + month;
  }
  if (date < 10) {
    date = '0' + date;
  }
  if (hour < 10) {
    hour = '0' + hour;
  }
  if (minu < 10) {
    minu = '0' + minu;
  }
  if (second < 10) {
    second = '0' + second;
  }
  return year + '-' + month + '-' + date;
};

export const NowDateTime = () => {
  var time = new Date();
  var year = time.getFullYear(); //获取年
  var month = time.getMonth() + 1; //或者月
  var date = time.getDate(); //或者天
  var hour = time.getHours(); //获取小时
  var minu = time.getMinutes(); //获取分钟
  var second = time.getSeconds(); //或者秒
  if (month < 10) {
    month = '0' + month;
  }
  if (date < 10) {
    date = '0' + date;
  }
  if (hour < 10) {
    hour = '0' + hour;
  }
  if (minu < 10) {
    minu = '0' + minu;
  }
  if (second < 10) {
    second = '0' + second;
  }
  return (
    year + '-' + month + '-' + date + ' ' + hour + ':' + minu + ':' + second
  );
};

export const getNextDate = day => {
  const date = new Date();
  date.setDate(date.getDate() + day); // 获取day天后的日期
  const y = date.getFullYear();
  const m = date.getMonth() + 1; // 获取当前月份的日期
  const d = date.getDate();
  const h = date.getHours(); //获取小时
  const min = date.getMinutes(); //获取分钟
  const s = date.getSeconds(); //或者秒
  return y + '-' + m + '-' + d + ' ' + h + ':' + min + ':' + s;
};

export const getStartDate = day => {
  const date = new Date();
  date.setDate(date.getDate() + 0);
  if (day) {
    date.setDate(date.getDate() + day);
  }
  const y = date.getFullYear();
  const m = date.getMonth() + 1; // 获取当前月份的日期
  const d = date.getDate();
  const h = '00'; //获取小时
  const min = '00'; //获取分钟
  const s = '00'; //或者秒
  return y + '-' + m + '-' + d + ' ' + h + ':' + min + ':' + s;
};

export const getEndDate = day => {
  const date = new Date();
  date.setDate(date.getDate());
  const y = date.getFullYear();
  const m = date.getMonth() + 1; // 获取当前月份的日期
  const d = date.getDate();
  const h = '23'; //获取小时
  const min = '59'; //获取分钟
  const s = '59'; //或者秒
  return y + '-' + m + '-' + d + ' ' + h + ':' + min + ':' + s;
};
